Create User
Create User Example
For creating a new user you need to use the createUser and provide a data object,
Here is the User class:
data class User(
    var id: String? = null,
    var name: String? = null,
    @SerializedName("phone_number") var phoneNumber: String? = null,
    var email: String? = null,
    @SerializedName("date_of_birth") var dateOfBirth: String? = null,
    var gender: Gender? = null,
    @SerializedName("insurance_id") var insuranceId: String? = null,
    @SerializedName("policy_number") var policyNumber: String? = null,
    @SerializedName("nationality_number") var nationalityNumber: String? = null,
    var height: Int? = null,
    var weight: Int? = null,
    @SerializedName("blood_type") var bloodType: BloodType? = null,
    var smoker: String? = null,
    var alcoholic: String? = null,
    @SerializedName("marital_status") var maritalStatus: MaritalStatus? = null,
    @SerializedName("relation_type") var relationType: RelationType? = null,
    @SerializedName("created_at") var createdAt: String? = null,
    @SerializedName("updated_at") var updatedAt: String? = null
)
Check the example for create user:
val user =  User(name = "user_name", email = "[email protected]")
ApiService.createUser(user, object : ApiCallback<User> {
    override fun onSuccess(response: User) {
    }
    override fun onFailure(error: String?) {
    }
    override fun onRequestError(error: String?) {
    }
})
Consider that not all User data are required
Responses
Status 201
Success
{
  "id": '999999999',
  "name": "Altibbi User",
  "email": "[email protected]",
  "date_of_birth": "2000-01-30",
  "createdAt": "2024-01-30",
  "updatedAt": "2024-01-30",
  "gender": "male",
  "insurance_id": "123123123",
  "policy_number": "111111111",
  "height": 180,
  "weight": 90,
  "blood_type": "A+",
  "smoker": "yes",
  "alcoholic": "no",
  "marital_status": "single",
  "relation_type": "brother"
}
Status 401
UnauthorizedHttpException represents an Unauthorized HTTP exception with status code 401.
{
  "name": "Unauthorized",
  "message": "Your request was made with invalid credentials",
  "code": "0",
  "status": "401",
  "type": "yii\\\\web\\\\UnauthorizedHttpException"
}
Status 422
Data Validation Failed.
[
  {
    "field": "string", 
    "message": "string"
  }
]